<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    // function fn() {
    //     var a = 1;
    //     return function () {
    //         return a++;
    //     }
    // }
    // var f1 = fn();
    // console.log(f1());
    // console.log(f1());

    // 函数防抖  
    document.onclick = (function () {
        var flag = false;
        return function () {
            if (flag) {
                return false;
            }
            flag = true;
            setTimeout(function () {
                console.log(111111);
                flag = false;
            }, 1000)
        }
    })();

    var scope = "global";
    function fn1() {
        var a = 1;
        var b = 2;
        return scope;
    }
    function fn2() {
        return scope;
    }
    console.log(fn1());
    console.log(fn2());

</script>

</html>